window.onload=()=>{

    //游戏资讯 信息栏显示与隐藏
    let game_list = document.getElementById('game')
    let game_info = document.getElementById('game_info')
    let list = document.getElementById('list')
    list.onmouseover = () => {
        game_info.style.display = 'block'
    }
    list.onmouseout = () => {
        game_info.style.display = 'none'
    }
//  切换微信微博二维码
let tab_bottom_img = document.getElementsByClassName('tab_bottom_img')
// let tab_top = document.querySelector('.tab_top')
let  as=document.getElementById('wbwx').getElementsByTagName('span');
for (let i = 0; i <  as.length; i++) {
     as[i].onclick = () => {
        for (let j = 0; j < tab_bottom_img.length; j++) {
            tab_bottom_img[j].style.display = 'none'
             as[j].className = ''
        }
         as[i].className = 'isactive'
        tab_bottom_img[i].style.display = 'block'
    }
}

//切换新闻四个按钮
 let r1_content_bottom=document.getElementsByClassName("r1_content_bottom");
// console.log(r1_content_bottom.length);
let r1_content_top=document.getElementsByClassName('r1_content_top')[0].getElementsByTagName('li')

//  console.log(r1_content_top.length);
for (let i = 0; i < r1_content_top.length; i++) {
    r1_content_top[i].onclick=()=>{
        for (let j = 0; j < r1_content_bottom.length; j++) {
            r1_content_bottom[j].style.display = 'none'
            r1_content_top[j].className=''
        }
        r1_content_top[i].className='isnews'
        r1_content_bottom[i].style.display = 'block'
    }
    
}
}
// 自动生成最新列表
// function creat(num){
 
//     let zuixin=document.getElementById('zx')
//     let str=''
//     for (let i = 0; i < num; i++) {
//         str='<a href="#"><span>命运WYD'+i+'：精炼异常BUG的情况及补偿公告</span><span>[2020/09/17]</span></a>'
//     }
//    zuixin.appendChild=str

// }

// creat(58)

// }

function goPage(pnum,psize){
    //js分页

//  console.log(zx.length);
/**
 * 分页函数
 * pnum--页数
 * psize--每页显示记录数
 * 分页部分是从真实数据行开始，因而存在加减某个常数，以确定真正的记录数
 * 纯js分页实质是数据行全部加载，通过是否显示属性完成分页功能
 **/
    let zx=document.getElementById('bottom_a').getElementsByTagName('a')
    let page=document.getElementById("page")
    let num=zx.length;//数据行数
    console.log(num);
    let totalPage=0//总页数
    let pageSize=psize;//每页显示行数
    console.log("goPage");
   
    //总共分几页
    if(num/pageSize>parseInt(num/pageSize)){
        totalPage=parseInt(num/pageSize)+1
    }else{
        totalPage=parseInt(num/pageSize)
    }
    let currentPage=pnum//当前页
    let  startRow=(currentPage-1) *pageSize+1//开始行
    let endRow=currentPage*pageSize//结束行
    //遍历数据显示 实现分页
    for (let i = 0; i < num; i++) {
       if (i>=startRow && i<=endRow ) {
           zx[i].style.display='block'
       }else{
        zx[i].style.display='none'

       }
    }
       let pageEnd = document.getElementById("pageEnd");
       let  tempStr = "<span>共"+num+"条记录</span> <span>分"+totalPage+"页</span><span>当前第"+currentPage+"页</span>";
        if (currentPage>1) {
            tempStr += "<a href=\"#\" onClick=\"goPage("+(1)+","+psize+")\">首页</a>";
            tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\"><上一页</a>"
        }else{
            tempStr += "<span>首页</span>";
            tempStr += "<span><上一页</span>";    
         }
        if(currentPage<totalPage){
            tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">下一页></a>";
            tempStr += "<a href=\"#\" onClick=\"goPage("+(totalPage)+","+psize+")\">尾页</a>";
         }else{
            tempStr += "<span>下一页></span>";
            tempStr += "<span>尾页</span>";    
         }
         
    document.getElementById("barcon").innerHTML = tempStr;
    }
    goPage(1,20)


